package com.base.controller

import com.yfree.config.YConfig
import com.yfree.global.YController
import kotlin.reflect.full.functions

fun YController.call(target: Any, jkid: String, jkparam: Any?): String? {
    return try {
        target::class.functions.find { function ->
            function.name == jkid
        }?.call(target, this, yParams(jkparam, Map::class.java)) as? String
    } catch (e: Exception) {
        if (YConfig.DEBUG) e.printStackTrace()
        yResult(code = 500, message = "系统内部错误：${if (YConfig.DEBUG) e.stackTraceToString() else "500"}")
    }
}
